// router.js
import {
	RouterMount,
	createRouter
} from 'uni-simple-router';
import store from './store/index.js'
const router = createRouter({
	platform: process.env.VUE_APP_PLATFORM,
	routes: [...ROUTES]
});
//全局路由前置守卫
router.beforeEach((to, from, next) => {
	//判断该页面是否需要拦截
	if (to.meta.checking) {
		//需要
		//是否已经登录
		if (store.state.userInfo) {
			next()
		} else {
			/*小程序拦截无效，除非是初始化拦截*/
			next({
				name: "login",
				NAVTYPE: "push" //跳转到普通页面，新开界面保留历史记录
			})
		}

	} else {
		//不需要
		next();
	}

});
// 全局路由后置守卫
router.afterEach((to, from) => {})

export {
	router,
	RouterMount
}
